<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.settings/org.eclipse.ltk.core.refactoring.prefs</filename>
    </added>
    <added>
      <filename>src/me/regexp/CharacterArrayCharacterIterator.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/CharacterCaseMap.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/CharacterClassMap1.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/CharacterClassMap2.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/CharacterClassMap3.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/CharacterClassMap4.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/CharacterIterator.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/RE.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/RECharacter.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/RECompiler.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/REDebugCompiler.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/REProgram.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/RESyntaxException.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/REUtil.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/ReaderCharacterIterator.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/StreamCharacterIterator.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/StringCharacterIterator.java</filename>
    </added>
    <added>
      <filename>src/me/regexp/StringReader.java</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff></diff>
      <filename>BrightBerry-1.debug</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>BrightBerry-2.debug</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>BrightBerry.cod</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>BrightBerry.debug</filename>
    </modified>
    <modified>
      <diff>@@ -1,23 +1,23 @@
 Manifest-Version: 1.0
-MIDlet-Version: 0.2.7
-MIDlet-Jar-Size: 383788
+MIDlet-Version: 0.2.8
+MIDlet-Jar-Size: 428294
 RIM-COD-URL-2: BrightBerry-2.cod
 MicroEdition-Configuration: CLDC-1.1
 MIDlet-Jar-URL: BrightBerry.jar
-RIM-COD-Module-Dependencies: net_rim_cldc,net_rim_bbapi_browser,net_rim_bbapi_menuitem,net_rim_os,net_rim_bbapi_invoke,net_rim_locationapi
+RIM-COD-Module-Dependencies: net_rim_cldc,net_rim_bbapi_browser,net_rim_bbapi_menuitem,net_rim_bbapi_mailv2,net_rim_os,net_rim_bbapi_invoke,net_rim_locationapi
 RIM-COD-URL-1: BrightBerry-1.cod
-RIM-COD-SHA1-2: 4c 51 0a 82 32 30 4f c3 3b db 02 a4 a2 4c 4a 37 e8 77 7d 61
-RIM-COD-SHA1-1: 43 a7 f9 fe 81 b7 cb cb 5d 47 44 a1 2d 87 d9 4e 2b 58 39 53
+RIM-COD-SHA1-2: fc 91 56 15 35 da 9c b1 e4 e4 19 1e 9f b1 7b c1 cc eb 0f ce
+RIM-COD-SHA1-1: bf a9 42 9f 33 9b 5f b2 e6 69 fa fc 06 b2 3a 67 60 6d 27 6a
 RIM-MIDlet-Flags-1: 0
-RIM-COD-Size-2: 20456
+RIM-COD-Size-2: 31968
 RIM-COD-Module-Name: BrightBerry
-RIM-COD-Size-1: 62028
-RIM-COD-Size: 62516
+RIM-COD-Size-1: 59324
+RIM-COD-Size: 71900
 MIDlet-Name: BrightBerry
-RIM-COD-Creation-Time: 1246926959
+RIM-COD-Creation-Time: 1247292660
 MIDlet-1: BrightBerry,img/BKIcon.jpg,
 RIM-COD-URL: BrightBerry.cod
 MIDlet-Description: Unofficial Blackberry app for Brightkite using the REST-API
-RIM-COD-SHA1: 82 73 75 8a 69 98 7a 79 a5 7d 86 3d ee d3 c7 69 ee b9 56 eb
+RIM-COD-SHA1: 03 9c e2 85 97 7e 4d a1 e6 c4 2f 0d d0 3f 2d 79 cf c7 78 8b
 MicroEdition-Profile: MIDP-2.0
 MIDlet-Vendor: Hallgren Networks</diff>
      <filename>BrightBerry.jad</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>BrightBerry.jar</filename>
    </modified>
    <modified>
      <diff>@@ -41,6 +41,24 @@ src\img\icon_private.gif
 src\img\icon_public.gif
 src\img\icon_settings.gif
 src\img\listArrow.png
+src\me\regexp\CharacterArrayCharacterIterator.java
+src\me\regexp\CharacterCaseMap.java
+src\me\regexp\CharacterClassMap1.java
+src\me\regexp\CharacterClassMap2.java
+src\me\regexp\CharacterClassMap3.java
+src\me\regexp\CharacterClassMap4.java
+src\me\regexp\CharacterIterator.java
+src\me\regexp\RE.java
+src\me\regexp\ReaderCharacterIterator.java
+src\me\regexp\RECharacter.java
+src\me\regexp\RECompiler.java
+src\me\regexp\REDebugCompiler.java
+src\me\regexp\REProgram.java
+src\me\regexp\RESyntaxException.java
+src\me\regexp\REUtil.java
+src\me\regexp\StreamCharacterIterator.java
+src\me\regexp\StringCharacterIterator.java
+src\me\regexp\StringReader.java
 src\mobi\bbhn\brightberry\AboutScreen.java
 src\mobi\bbhn\brightberry\AvatarThread.java
 src\mobi\bbhn\brightberry\BkObjectScreen.java
@@ -144,4 +162,4 @@ Title=BrightBerry
 Type=0
 UserData=|src
 Vendor=Hallgren Networks
-Version=0.2.7
+Version=0.2.8</diff>
      <filename>BrightBerry.jdp</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 MIDlet-Name: BrightBerry
-MIDlet-Version: 0.2.7
+MIDlet-Version: 0.2.8
 MIDlet-Vendor: Hallgren Networks
 MIDlet-Description: Unofficial Blackberry app for Brightkite using the REST-API
 MIDlet-Jar-URL: BrightBerry.jar</diff>
      <filename>BrightBerry.rapc</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,20 @@
-=== 0.2.8 TODOs
+=== 0.2.9 TODOs
 * New Features
  * Viewing user details
  * Viewing comments stream
  * Sending friends requests
  
+=== 0.2.8
+ * New Features
+  * You can now search in placemarks by pressing a key when the list is displayed.
+  * Will now display a message if Brightkite is overloaded (And take you back to the main screen)
+  * Will now display a message if you account is invalid such as username and/or password issue (And take you back to the settings screen)
+  
+ * Fixes
+  * Thread for WhereAmI would run excessivly and unpredictally. Now only calls when the program is brought from the background, user requests an update, or user checks in elsewhere
+  * Freed up resources after they were used.
+  * Removed friend count varabile since its not used for right now.
+  
 === 0.2.7
 * New Features
  * You can now accept friend requests</diff>
      <filename>CHANGELOG.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -57,8 +57,5 @@ public class AboutScreen extends MainScreen {
         add(gpswarn);
         add(new SeparatorField());
         add(new RichTextField(&quot;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \&quot;AS IS\&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&quot;));
-        RichTextField gregbutt = new RichTextField(&quot;@gregz is a butthead!&quot;);
-        gregbutt.setFont(this.getFont().derive(Font.DROP_SHADOW_RIGHT_EFFECT));
-        add(gregbutt);
 	}
 }</diff>
      <filename>src/mobi/bbhn/brightberry/AboutScreen.java</filename>
    </modified>
    <modified>
      <diff>@@ -18,6 +18,9 @@ public class AvatarThread extends Thread {
 	private String user;
 	private String url;
 	static Settings settings = Settings.getInstance();
+	HttpConnection httpConnection = null;
+	DataInputStream iStrm = null;
+	ByteArrayOutputStream bStrm = null;
 
 	public AvatarThread(String user, String url) {
 		this.user = user;
@@ -30,31 +33,29 @@ public class AvatarThread extends Thread {
 			System.out.println(&quot;Avatar Thread user: &quot; + this.user);
 			System.out.println(&quot;Avatar &quot; + user + &quot; Start: &quot; + start.toString());
 			this.url += NetworkConfig.getConnectionParameters(settings.getConnectionMode());
-			HttpConnection httpConnection = ((HttpConnection)Connector.open(this.url));
-			httpConnection.setRequestProperty(&quot;User-Agent&quot;, BrightBerry.useragent);
-			httpConnection.setRequestProperty(&quot;Content-Language&quot;, &quot;en-US&quot;);
-			httpConnection.setRequestProperty(&quot;Accept&quot;, &quot;*/*&quot;);
-			httpConnection.setRequestProperty(&quot;Connection&quot;, &quot;Keep-Alive&quot;);
-			httpConnection.setRequestProperty(&quot;Accept-Encoding&quot;, &quot;gzip,deflate&quot;);
-			httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
+			this.httpConnection = ((HttpConnection)Connector.open(this.url));
+			this.httpConnection.setRequestProperty(&quot;User-Agent&quot;, BrightBerry.useragent);
+			this.httpConnection.setRequestProperty(&quot;Content-Language&quot;, &quot;en-US&quot;);
+			this.httpConnection.setRequestProperty(&quot;Accept&quot;, &quot;*/*&quot;);
+			this.httpConnection.setRequestProperty(&quot;Connection&quot;, &quot;Keep-Alive&quot;);
+			this.httpConnection.setRequestProperty(&quot;Accept-Encoding&quot;, &quot;gzip,deflate&quot;);
+			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			int rc = httpConnection.getResponseCode();
 			if (rc == HttpConnection.HTTP_OK) {
-				DataInputStream iStrm = httpConnection.openDataInputStream();
+				this.iStrm = this.httpConnection.openDataInputStream();
 				byte imageData[];
-				int length = (int) httpConnection.getLength();
+				int length = (int) this.httpConnection.getLength();
 				if (length != -1) {
 					imageData = new byte[length];
-					iStrm.readFully(imageData);
+					this.iStrm.readFully(imageData);
 				} else {
-					ByteArrayOutputStream bStrm = new ByteArrayOutputStream();
-	
+					this.bStrm = new ByteArrayOutputStream();
 					int ch;
 					while ((ch = iStrm.read()) != -1) {
-						bStrm.write(ch);
+						this.bStrm.write(ch);
 					}
-		
-					imageData = bStrm.toByteArray();
-					bStrm.close();
+					imageData = this.bStrm.toByteArray();
+					this.bStrm.close();
 				}
 				EncodedImage m_Image = EncodedImage.createEncodedImage(imageData, 0, imageData.length);
 				int oldHeight = m_Image.getHeight();
@@ -71,10 +72,19 @@ public class AvatarThread extends Thread {
 				Date end = new Date();
 				System.out.println(&quot;Avatar &quot; + user + &quot; End: &quot; + end.toString());
 			} else {
+				BrightBerry.displayAlert(&quot;Unable to get avatar&quot;, &quot;Brightberry was unable to get the avator for &quot; + user + &quot; using the default one&quot;);
 				System.out.println(&quot;Could not get Avatar for &quot; + user);
 				Date end = new Date();
 				System.out.println(&quot;Avatar &quot; + user + &quot; End: &quot; + end.toString());
 			}
+			if (this.iStrm != null) {
+				this.iStrm.close();
+				System.out.println(&quot;Input stream closed&quot;);
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
+				System.out.println(&quot;Http connection closed&quot;);
+			}
 		} catch (IOException e) {
 			System.out.println(&quot;Got an exception: &quot; + e.toString());
 		}</diff>
      <filename>src/mobi/bbhn/brightberry/AvatarThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -40,7 +40,6 @@ public class BkObjectThread extends Thread {
 	String url = &quot;http://brightkite.com/objects/&quot;;
 	HttpConnection httpConnection = null;
 	InputStream httpInput = null;
-	String serverResponse = &quot;&quot;;
 	private String body = &quot;&quot;;
 	private String creator;
 	private BkObjectScreen screen;
@@ -66,18 +65,29 @@ public class BkObjectThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;Authorization&quot;, this.settings.getAuthHeader());
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			this.httpInput = this.httpConnection.openInputStream();
-
-			StringBuffer buffer = new StringBuffer();
-
-			int ch = 0;
-			while (ch != -1) {
-				ch = this.httpInput.read();
-				buffer.append((char)ch);
+			int rc = this.httpConnection.getResponseCode();
+			if (rc == 503) {
+				BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+			} else if (rc == 401 || rc == 403) {
+				BrightBerry.errorUnauthorized();
+			} else {
+				StringBuffer buffer = new StringBuffer();
+				int ch = 0;
+				while (ch != -1) {
+					ch = this.httpInput.read();
+					buffer.append((char)ch);
+				}
+				parseJSON(buffer.toString());
+				this.screen.updateObject(type, body, creator, location, created_at_as_words, about, photo, commentscount);
+			}
+			if (this.httpInput != null) {
+				this.httpInput.close();
+				System.out.println(&quot;HTTP Input closed&quot;);
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
+				System.out.println(&quot;HTTP Connection closed&quot;);
 			}
-
-			this.serverResponse = buffer.toString();
-			parseJSON(this.serverResponse);
-			this.screen.updateObject(type, body, creator, location, created_at_as_words, about, photo, commentscount);
 	    } catch (IOException ex) {
 	    	ex.printStackTrace();
 	    }</diff>
      <filename>src/mobi/bbhn/brightberry/BkObjectThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -102,6 +102,11 @@ public class BlockUserThread extends Thread {
 					((DirectMessageSentScreen) this.screen).callBlocked(true);
 				}
 			} else {
+				if (rc == 503) {
+					BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+				} else if (rc == 401 || rc == 403) {
+					BrightBerry.errorUnauthorized();
+				}
 				if (this.caller.equals(&quot;FriendsScreen&quot;)) {
 					((FriendsScreen) this.screen).callBlocked(false);
 				} else if (this.caller.equals(&quot;DirectMessageRcvScreen&quot;)) {
@@ -110,6 +115,15 @@ public class BlockUserThread extends Thread {
 					((DirectMessageSentScreen) this.screen).callBlocked(false);
 				}
 			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
+			}
+			if (this.httpInput != null) {
+				this.httpInput.close();
+			}
+			if (this.httpOutput != null) {
+				this.httpOutput.close();
+			}
 			System.out.println(&quot;Post was: &quot; + this.poststring);
 			System.out.println(&quot;Auth was: &quot;+ Settings.getInstance().getAuthHeader());
 			System.out.println(&quot;Response code was: &quot; + rc);</diff>
      <filename>src/mobi/bbhn/brightberry/BlockUserThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -28,10 +28,19 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
 OF SUCH DAMAGE.
 */
 
+import me.regexp.RE;
+import net.rim.blackberry.api.mail.Address;
+import net.rim.blackberry.api.mail.MessagingException;
+import net.rim.blackberry.api.mail.NoSuchServiceException;
+import net.rim.blackberry.api.mail.Session;
+import net.rim.blackberry.api.mail.Store;
+import net.rim.blackberry.api.mail.event.FolderEvent;
+import net.rim.blackberry.api.mail.event.FolderListener;
 import net.rim.blackberry.api.menuitem.ApplicationMenuItem;
 import net.rim.blackberry.api.menuitem.ApplicationMenuItemRepository;
 import net.rim.device.api.applicationcontrol.ApplicationPermissions;
 import net.rim.device.api.applicationcontrol.ApplicationPermissionsManager;
+import net.rim.device.api.system.Alert;
 import net.rim.device.api.system.Application;
 import net.rim.device.api.system.ApplicationDescriptor;
 import net.rim.device.api.system.Bitmap;
@@ -47,7 +56,7 @@ import net.rim.device.api.ui.component.LabelField;
 import net.rim.device.api.ui.component.SeparatorField;
 
 public class BrightBerry extends UiApplication {
-	static String version = &quot;0.2.7-ALPHA&quot;;
+	static String version = &quot;0.2.8-ALPHA&quot;;
 	static String gmkey = &quot;ABQIAAAAyqsOf4y12VmEo_2G0kkmUxRpIJO9csrDHHCYF6wRDNKwcymzzRQrUdTZ3AkMMnIbfqA_JKHMK0MjHw&quot;;
 	static String useragent = &quot;BrightBerry &quot; + version;
 	static int itembgcolor = Color.WHITE;
@@ -57,15 +66,43 @@ public class BrightBerry extends UiApplication {
 	static int buttonbgcolor = Color.WHITE;
 	static int buttonhlcolor = Color.LIGHTBLUE;
 	static int pendingFriends;
-	static int friendCount;
 	static int unreadMessages;
+	static String currentPlace;
+	static String currentPlaceID;
 	final static long RUNSTORE = 0xb1850218a6a07789L;
 	static ApplicationMenuItem imagemenu = new BrightBerryPhotoMenuItem();
 	static long locationToAddMenuItem = ApplicationMenuItemRepository.MENUITEM_FILE_EXPLORER;
     static ApplicationMenuItemRepository amir = ApplicationMenuItemRepository.getInstance();
     static ApplicationDescriptor app = ApplicationDescriptor.currentApplicationDescriptor();
+	private static boolean background = true;
 	
 	public static void main(String[] args) {
+		Store store = Session.getDefaultInstance().getStore();
+		store.addFolderListener(new FolderListener() {
+			   public void messagesAdded(FolderEvent e) {
+				   if (e.getMessage().isInbound() == true) {
+						try {
+							Address from = e.getMessage().getFrom();
+							if (from.getAddr().toString().endsWith(&quot;no-reply@brightkite.com&quot;)) {
+								Alert.startVibrate(3000);
+								System.out.println(&quot;Brightkite Message!!!&quot;);
+								RE r = new RE(&quot;http://brightkite.com/objects/[A-za-z0-9]$&quot;);
+								boolean matched = r.match(e.getMessage().getBodyText());
+								System.out.println(&quot;Object Match&quot; + matched);
+							}
+						} catch (MessagingException e1) {
+						}
+						System.out.println(&quot;New email is inbound&quot;);
+						System.out.println(&quot;Subject is: &quot; + e.getMessage().getSubject());
+				   }
+			   }
+
+				public void messagesRemoved(FolderEvent e) {
+					System.out.println(&quot;Message Deleted&quot;);
+					System.out.println(&quot;Subject is: &quot; + e.getMessage().getSubject());
+				}
+			});
+		
         amir.addMenuItem(locationToAddMenuItem, imagemenu, app);
         
 		BrightBerry instance = new BrightBerry();
@@ -144,14 +181,6 @@ public class BrightBerry extends UiApplication {
 		BrightBerry.pendingFriends = count;
 	}
 	
-	public static int getFriendCount() {
-		return BrightBerry.friendCount;
-	}
-	
-	public static void setFriendCount(int count) {
-		BrightBerry.friendCount = count;
-	}
-	
 	public static int getUnreadMessages() {
 		return BrightBerry.unreadMessages;
 	}
@@ -159,6 +188,22 @@ public class BrightBerry extends UiApplication {
 	public static void setUnreadMessages(int count) {
 		BrightBerry.unreadMessages = count;
 	}
+	
+	public static void setCurrentPlace(String currentPlace) {
+		BrightBerry.currentPlace = currentPlace;
+	}
+	
+	public static String getCurrentPlace() {
+		return BrightBerry.currentPlace;
+	}
+	
+	public static void setCurrentPlaceID(String currentPlaceID) {
+		BrightBerry.currentPlaceID = currentPlaceID;
+	}
+	
+	public static String getCurrentPlaceID() {
+		return BrightBerry.currentPlaceID;
+	}
     
 	private static class BrightBerryPhotoMenuItem extends ApplicationMenuItem {
 		BrightBerryPhotoMenuItem() {
@@ -194,4 +239,40 @@ public class BrightBerry extends UiApplication {
 	    	System.out.println(&quot;Unable to remove item&quot;);
 	    }
 	}
+	
+	public static void displayAlert(String title, final String message) {
+		final Screen _screen = new Dialog(Dialog.D_OK, title + &quot;:&quot;, Dialog.D_OK, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.VERTICAL_SCROLL);		
+		LabelField _text = new LabelField(message);
+		_screen.add(_text);
+		UiApplication.getUiApplication().invokeLater (new Runnable() {
+		    public void run() {
+		    	if (message.equals(&quot;Your username and/or password do not match!&quot;)) {
+		    		UiApplication.getUiApplication().pushScreen(new SettingsScreen());
+			    	while (UiApplication.getUiApplication().getScreenCount() &gt;= 2) {
+			    		UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
+			    	}
+		    	}
+		    	UiApplication.getUiApplication().pushGlobalScreen(_screen, 1, GLOBAL_MODAL);
+		    }
+		});
+	}
+	
+	public static void errorUnauthorized() {
+		Settings settings = Settings.getInstance();
+		settings.setAuthed(false);
+		Settings.save(settings);
+		BrightBerry.displayAlert(&quot;Error&quot;, &quot;Your username and/or password do not match!&quot;);
+	}
+
+	public static void toBackground() {
+		BrightBerry.background = true;
+	}
+	
+	public static void fromBackground() {
+		BrightBerry.background = false;
+	}
+	
+	public static boolean isBackground() {
+		return BrightBerry.background;
+	}
 }
\ No newline at end of file</diff>
      <filename>src/mobi/bbhn/brightberry/BrightBerry.java</filename>
    </modified>
    <modified>
      <diff>@@ -68,12 +68,10 @@ public class BrightBerryMain extends MainScreen {
 	private MenuItem privacymodeItem;
 	private boolean priupdated;
 	private MenuItem licenseItem;
-	private BrightBerryMain screen = this;
 	private MenuItem refreshlocItem;
 	private boolean upgradeavailable;
 	private MenuItem upgradeItem;
 	private MenuItem latestnewsItem;
-	private static String locationName;
 	
     public BrightBerryMain() {
     	super.setTitle(new LabelField(&quot;BrightBerry&quot;, 1152921504606846980L));
@@ -142,7 +140,7 @@ public class BrightBerryMain extends MainScreen {
 		
 		this.refreshlocItem = new MenuItem(&quot;Refresh Location&quot;, 1, 10) {
 			public void run() {
-				Thread whereThread = new WhereAmIThread(BrightBerryMain.this.screen);
+				Thread whereThread = new WhereAmIThread(BrightBerryMain.this);
 				whereThread.start();
 			}
 		};
@@ -267,46 +265,46 @@ public class BrightBerryMain extends MainScreen {
 		});
     }
     
-    public void updateLocation(String locName){
-		BrightBerryMain.locationName = locName;
-		UiApplication.getUiApplication().invokeLater(
-			new Runnable() {
-				public void run() {
-					System.out.println(&quot;Checked in at &quot; + BrightBerryMain.locationName);
-					VerticalFieldManager vfm = new VerticalFieldManager();
-					vfm.add(new SeparatorField());
-					LabelField locationLabel = new LabelField(&quot;You're checked in @ &quot; + BrightBerryMain.locationName);
-					vfm.add(locationLabel);
-					if (BrightBerry.getPendingFriends() == 1) {
-						LabelField friendsLabel = new LabelField(&quot;You have &quot; +  BrightBerry.getPendingFriends() + &quot; pending friend request!&quot;);
-						vfm.add(friendsLabel);
-					}
-					if (BrightBerry.getPendingFriends() &gt; 1) {
-						LabelField friendsLabel = new LabelField(&quot;You have &quot; +  BrightBerry.getPendingFriends() + &quot; pending friend requests!&quot;);
-						vfm.add(friendsLabel);
-					}
-					if (BrightBerry.getUnreadMessages() == 1) {
-						LabelField unreadLabel = new LabelField(&quot;You have &quot; + BrightBerry.getUnreadMessages() + &quot; new message!&quot;);
-						vfm.add(unreadLabel);
-					}
-					if (BrightBerry.getUnreadMessages() &gt; 1) {
-						LabelField unreadLabel = new LabelField(&quot;You have &quot; + BrightBerry.getUnreadMessages() + &quot; new messages!&quot;);
-						vfm.add(unreadLabel);
-					}
-					BrightBerryMain.this.setStatus(vfm);
-				}
-			});
-	}
-    
     public boolean onClose() {
+    	BrightBerry.toBackground();
 		UiApplication.getUiApplication().requestBackground();
 		return true;
 	}
     
     protected void onFocusNotify(boolean focus) {
-    	if (this.settings.getAuthed() &amp;&amp; this.settings.getAutoWhereAmI() &amp;&amp; focus) {
-    		Thread whereThread = new WhereAmIThread(this.screen);
+    	if (this.settings.getAuthed() &amp;&amp; this.settings.getAutoWhereAmI() &amp;&amp; focus &amp;&amp; BrightBerry.isBackground()) {
+    		Thread whereThread = new WhereAmIThread(this);
 			whereThread.start();
+			BrightBerry.fromBackground();
     	}
+    	System.out.println(&quot;onFocusNotify: &quot; + focus);
+    }
+    
+    public void updateCurrentPlace() {
+    	UiApplication.getUiApplication().invokeLater(new Runnable() {
+			public void run() {
+		    	VerticalFieldManager vfm = new VerticalFieldManager();
+				vfm.add(new SeparatorField());
+				LabelField locationLabel = new LabelField(&quot;You're checked in @ &quot; + BrightBerry.getCurrentPlace());
+				vfm.add(locationLabel);
+				if (BrightBerry.getPendingFriends() == 1) {
+					LabelField friendsLabel = new LabelField(&quot;You have &quot; +  BrightBerry.getPendingFriends() + &quot; pending friend request!&quot;);
+					vfm.add(friendsLabel);
+				}
+				if (BrightBerry.getPendingFriends() &gt; 1) {
+					LabelField friendsLabel = new LabelField(&quot;You have &quot; +  BrightBerry.getPendingFriends() + &quot; pending friend requests!&quot;);
+					vfm.add(friendsLabel);
+				}
+				if (BrightBerry.getUnreadMessages() == 1) {
+					LabelField unreadLabel = new LabelField(&quot;You have &quot; + BrightBerry.getUnreadMessages() + &quot; new message!&quot;);
+					vfm.add(unreadLabel);
+				}
+				if (BrightBerry.getUnreadMessages() &gt; 1) {
+					LabelField unreadLabel = new LabelField(&quot;You have &quot; + BrightBerry.getUnreadMessages() + &quot; new messages!&quot;);
+					vfm.add(unreadLabel);
+				}
+				BrightBerryMain.this.setStatus(vfm);
+			}
+    	});
     }
 }</diff>
      <filename>src/mobi/bbhn/brightberry/BrightBerryMain.java</filename>
    </modified>
    <modified>
      <diff>@@ -67,26 +67,41 @@ public class CheckInThread extends Thread {
 			this.httpOutput = this.httpConnection.openDataOutputStream();
 			this.httpOutput.write(this.message.getBytes());
 			this.httpInput = this.httpConnection.openInputStream();
-
-			StringBuffer buffer = new StringBuffer();
-
-			int ch = 0;
-			while (ch != -1) {
-				ch = this.httpInput.read();
-				buffer.append((char)ch);
+			int rc = this.httpConnection.getResponseCode();
+			if (rc == 503) {
+				BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+			} else if (rc == 401 || rc == 403) {
+				BrightBerry.errorUnauthorized();
+			} else {
+				StringBuffer buffer = new StringBuffer();
+				int ch = 0;
+				while (ch != -1) {
+					ch = this.httpInput.read();
+					buffer.append((char)ch);
+				}
+				this.serverResponse = buffer.toString();
+				if (this.caller.equals(&quot;placemark&quot;)) {
+					((PlacemarkScreen) this.screen).updateStatus(parseJSON(this.serverResponse));
+				} else if (this.caller.equals(&quot;search&quot;)) {
+					((SearchPlaceScreen) this.screen).updateStatus(parseJSON(this.serverResponse));
+				} else if (this.caller.equals(&quot;stream&quot;)) {
+					((StreamScreen) this.screen).updateStatus(parseJSON(this.serverResponse));
+				} else if (this.caller.equals(&quot;friends&quot;)) {
+					((FriendsScreen) this.screen).updateStatus(parseJSON(this.serverResponse));
+				}
+				BrightBerry.toBackground();
 			}
-
-			this.serverResponse = buffer.toString();
-			if (this.caller.equals(&quot;placemark&quot;)) {
-				((PlacemarkScreen) this.screen).updateStatus(parseJSON(this.serverResponse));
-			} else if (this.caller.equals(&quot;search&quot;)) {
-				((SearchPlaceScreen) this.screen).updateStatus(parseJSON(this.serverResponse));
-			} else if (this.caller.equals(&quot;stream&quot;)) {
-				((StreamScreen) this.screen).updateStatus(parseJSON(this.serverResponse));
-			} else if (this.caller.equals(&quot;friends&quot;)) {
-				((FriendsScreen) this.screen).updateStatus(parseJSON(this.serverResponse));
+			if (this.httpInput != null) {
+				this.httpInput.close();
+			}
+			if (this.httpOutput != null) {
+				this.httpOutput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
 			}
 		} catch (IOException ex) {
+			System.out.println(&quot;Caught exception: &quot; + ex.toString());
 		}
 	}
 	</diff>
      <filename>src/mobi/bbhn/brightberry/CheckInThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -29,7 +29,6 @@ OF SUCH DAMAGE.
 */
 
 import java.io.IOException;
-import java.io.InputStream;
 
 import javax.microedition.io.Connector;
 import javax.microedition.io.HttpConnection;
@@ -38,9 +37,8 @@ import net.rim.device.api.io.Base64OutputStream;
 
 public class CheckUsername {
 	Settings settings = Settings.getInstance();
-	String url = &quot;http://brightkite.com/me.json&quot;;
+	String url = &quot;http://brightkite.com/me/config.json&quot;;
 	HttpConnection httpConnection = null;
-	InputStream httpInput = null;
 	String serverResponse = &quot;&quot;;
 	String username;
 	String password;
@@ -64,11 +62,15 @@ public class CheckUsername {
 			this.httpConnection.setRequestProperty(&quot;Authorization&quot;, &quot;Basic &quot; + Base64OutputStream.encodeAsString(combo.getBytes(), 0, combo.getBytes().length, false, false));
 			int rc = httpConnection.getResponseCode();
 			System.out.println(&quot;Response code; &quot; + rc);
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
+			}
 			if (rc == HttpConnection.HTTP_OK) {
 				return true;
 			} else {
 				return false;
 			}
+			
 	    } catch (IOException ex) {
 	    	System.out.println(&quot;Caught exception&quot;);
 	    	ex.printStackTrace();</diff>
      <filename>src/mobi/bbhn/brightberry/CheckUsername.java</filename>
    </modified>
    <modified>
      <diff>@@ -61,18 +61,28 @@ class CommentThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;Content-Language&quot;, &quot;en-US&quot;);
 			this.httpConnection.setRequestProperty(&quot;Authorization&quot;, this.settings.getAuthHeader());
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
-
-			this.httpInput = this.httpConnection.openInputStream();
-			StringBuffer buffer = new StringBuffer();
-
-			int ch = 0;
-			while (ch != -1) {
-				ch = this.httpInput.read();
-				buffer.append((char)ch);
+			int rc = this.httpConnection.getResponseCode();
+			if (rc == 503) {
+				BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+			} else if (rc == 401 || rc == 403) {
+				BrightBerry.errorUnauthorized();
+			} else {
+				this.httpInput = this.httpConnection.openInputStream();
+				StringBuffer buffer = new StringBuffer();
+	
+				int ch = 0;
+				while (ch != -1) {
+					ch = this.httpInput.read();
+					buffer.append((char)ch);
+				}
+				this.screen.updateComments(parseJSON(buffer.toString()));
+			}
+			if (this.httpInput != null) {
+				this.httpInput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
 			}
-
-			this.serverResponse = buffer.toString();
-			this.screen.updateComments(parseJSON(this.serverResponse));
 		} catch (IOException ex) {
 			ex.printStackTrace();
 		}</diff>
      <filename>src/mobi/bbhn/brightberry/CommentThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -28,9 +28,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
 OF SUCH DAMAGE.
 */
 
-import java.io.DataOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 import javax.microedition.io.Connector;
 import javax.microedition.io.HttpConnection;
@@ -38,8 +36,6 @@ import javax.microedition.io.HttpConnection;
 public class DeleteObjectThread extends Thread {
 	String url = &quot;http://brightkite.com/objects/&quot;;
 	HttpConnection httpConnection = null;
-	InputStream httpInput = null;
-	DataOutputStream httpOutput = null;
 	String serverResponse = &quot;&quot;;
 	StreamScreen screen;
 	Settings settings = Settings.getInstance();
@@ -61,14 +57,22 @@ public class DeleteObjectThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;User-Agent&quot;, BrightBerry.useragent);
 			this.httpConnection.setRequestProperty(&quot;Authorization&quot;, this.settings.getAuthHeader());
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
-			this.httpOutput = this.httpConnection.openDataOutputStream();
-			this.httpInput = this.httpConnection.openInputStream();
 			int rc = httpConnection.getResponseCode();
 			System.out.println(&quot;Response code: &quot; + rc);
 			if (rc == 200) {
 				this.screen.callDelete(true, type, listindex);
 			} else {
-				this.screen.callDelete(false, type, listindex);
+				if (rc == 503) {
+					BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+					this.screen.callDelete(false, type, listindex);
+				} else if (rc == 401 || rc == 403) {
+					BrightBerry.errorUnauthorized();
+				} else {
+					this.screen.callDelete(false, type, listindex);
+				}
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
 			}
 	    } catch (IOException ex) {
 	    	ex.printStackTrace();</diff>
      <filename>src/mobi/bbhn/brightberry/DeleteObjectThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -28,9 +28,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
 OF SUCH DAMAGE.
 */
 
-import java.io.DataOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 import javax.microedition.io.Connector;
 import javax.microedition.io.HttpConnection;
@@ -38,8 +36,6 @@ import javax.microedition.io.HttpConnection;
 public class DeletePlacemarkThread extends Thread {
 	String url = &quot;http://brightkite.com/me/placemarks/&quot;;
 	HttpConnection httpConnection = null;
-	InputStream httpInput = null;
-	DataOutputStream httpOutput = null;
 	String serverResponse = &quot;&quot;;
 	PlacemarkScreen screen;
 	Settings settings = Settings.getInstance();
@@ -57,14 +53,22 @@ public class DeletePlacemarkThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;User-Agent&quot;, BrightBerry.useragent);
 			this.httpConnection.setRequestProperty(&quot;Authorization&quot;, this.settings.getAuthHeader());
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
-			this.httpOutput = this.httpConnection.openDataOutputStream();
-			this.httpInput = this.httpConnection.openInputStream();
 			int rc = httpConnection.getResponseCode();
 			System.out.println(&quot;Response code: &quot; + rc);
 			if (rc == 200) {
 				this.screen.callDelete(true);
 			} else {
-				this.screen.callDelete(false);
+				if (rc == 503) {
+					BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+					this.screen.callDelete(false);
+				} else if (rc == 401 || rc == 403) {
+					BrightBerry.errorUnauthorized();
+				} else {
+					this.screen.callDelete(false);
+				}
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
 			}
 	    } catch (IOException ex) {
 	    	ex.printStackTrace();</diff>
      <filename>src/mobi/bbhn/brightberry/DeletePlacemarkThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -74,6 +74,9 @@ public class DirectMessageRcvDeleteThread extends Thread {
 			} else {
 				this.screen.callDelete(false, this.sel);
 			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
+			}
 	    } catch (IOException ex) {
 	    	ex.printStackTrace();
 	    }</diff>
      <filename>src/mobi/bbhn/brightberry/DirectMessageRcvDeleteThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -61,16 +61,27 @@ class DirectMessageRcvThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;Authorization&quot;, this.settings.getAuthHeader());
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			this.httpInput = this.httpConnection.openInputStream();
-			StringBuffer buffer = new StringBuffer();
-
-			int ch = 0;
-			while (ch != -1) {
-				ch = this.httpInput.read();
-				buffer.append((char)ch);
+			int rc = this.httpConnection.getResponseCode();
+			
+			if (rc == 503) {
+				BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+			} else if (rc == 401 || rc == 403) {
+				BrightBerry.errorUnauthorized();
+			} else {
+				StringBuffer buffer = new StringBuffer();
+				int ch = 0;
+				while (ch != -1) {
+					ch = this.httpInput.read();
+					buffer.append((char)ch);
+				}
+				this.screen.updateMessages(parseJSON(buffer.toString()));
+			}
+			if (this.httpInput != null) {
+				this.httpInput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
 			}
-
-			this.serverResponse = buffer.toString();
-			this.screen.updateMessages(parseJSON(this.serverResponse));
 		} catch (IOException ex) {
 			ex.printStackTrace();
 		}</diff>
      <filename>src/mobi/bbhn/brightberry/DirectMessageRcvThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -61,16 +61,26 @@ class DirectMessageSentThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;Authorization&quot;, this.settings.getAuthHeader());
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			this.httpInput = this.httpConnection.openInputStream();
-			StringBuffer buffer = new StringBuffer();
-
-			int ch = 0;
-			while (ch != -1) {
-				ch = this.httpInput.read();
-				buffer.append((char)ch);
+			int rc = this.httpConnection.getResponseCode();
+			if (rc == 503) {
+				BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+			} else if (rc == 401 || rc == 403) {
+				BrightBerry.errorUnauthorized();
+			} else {
+				StringBuffer buffer = new StringBuffer();
+				int ch = 0;
+				while (ch != -1) {
+					ch = this.httpInput.read();
+					buffer.append((char)ch);
+				}
+				this.screen.updateMessages(parseJSON(buffer.toString()));
+			}
+			if (this.httpInput != null) {
+				this.httpInput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
 			}
-
-			this.serverResponse = buffer.toString();
-			this.screen.updateMessages(parseJSON(this.serverResponse));
 		} catch (IOException ex) {
 			ex.printStackTrace();
 		}</diff>
      <filename>src/mobi/bbhn/brightberry/DirectMessageSentThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,6 @@ OF SUCH DAMAGE.
 
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 import javax.microedition.io.Connector;
 import javax.microedition.io.HttpConnection;
@@ -41,7 +40,6 @@ import net.rim.device.api.system.Alert;
 public class FriendAcceptThread extends Thread {
 	String url = &quot;http://brightkite.com/me/friendship.json&quot;;
 	HttpConnection httpConnection = null;
-	InputStream httpInput = null;
 	DataOutputStream httpOutput = null;
 	String serverResponse = &quot;&quot;;
 	FriendsScreen screen;
@@ -67,7 +65,6 @@ public class FriendAcceptThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			this.httpOutput = this.httpConnection.openDataOutputStream();
 			this.httpOutput.write(this.poststring.getBytes());
-			this.httpInput = this.httpConnection.openInputStream();
 			int rc = httpConnection.getResponseCode();
 			if (rc == 201) {
 				if (Alert.isVibrateSupported() &amp;&amp; settings.getVibrateOnPost()) {
@@ -75,8 +72,19 @@ public class FriendAcceptThread extends Thread {
 				}
 				this.screen.callAccepted(true);
 			} else {
+				if (rc == 503) {
+					BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+				} else if (rc == 401 || rc == 403) {
+					BrightBerry.errorUnauthorized();
+				}
 				this.screen.callAccepted(false);
 			}
+			if (this.httpOutput != null) {
+				this.httpOutput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
+			}
 			System.out.println(&quot;Post was: &quot; + this.poststring);
 			System.out.println(&quot;Auth was: &quot;+ Settings.getInstance().getAuthHeader());
 			System.out.println(&quot;Response code was: &quot; + rc);</diff>
      <filename>src/mobi/bbhn/brightberry/FriendAcceptThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -61,16 +61,26 @@ class FriendsThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;Authorization&quot;, this.settings.getAuthHeader());
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			this.httpInput = this.httpConnection.openInputStream();
-			StringBuffer buffer = new StringBuffer();
-
-			int ch = 0;
-			while (ch != -1) {
-				ch = this.httpInput.read();
-				buffer.append((char)ch);
+			int rc = this.httpConnection.getResponseCode();
+			if (rc == 503) {
+				BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+			} else if (rc == 401 || rc == 403) {
+				BrightBerry.errorUnauthorized();
+			} else {
+				StringBuffer buffer = new StringBuffer();
+				int ch = 0;
+				while (ch != -1) {
+					ch = this.httpInput.read();
+					buffer.append((char)ch);
+				}
+				this.screen.updateFriends(parseJSON(buffer.toString()));
+			}
+			if (this.httpInput != null) {
+				this.httpInput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
 			}
-
-			this.serverResponse = buffer.toString();
-			this.screen.updateFriends(parseJSON(this.serverResponse));
 		} catch (IOException ex) {
 			ex.printStackTrace();
 		}</diff>
      <filename>src/mobi/bbhn/brightberry/FriendsThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -84,6 +84,12 @@ public class HTTPPhoto {
 				imageData = bStrm.toByteArray();
 				bStrm.close();
 			}
+			if (iStrm != null) {
+				iStrm.close();
+			}
+			if (httpConnection != null) {
+				httpConnection.close();
+			}
 			EncodedImage m_Image = EncodedImage.createEncodedImage(imageData, 0, imageData.length);
 			int oldWidth = m_Image.getWidth();
 			int screenWidth = Display.getWidth();
@@ -95,7 +101,6 @@ public class HTTPPhoto {
 			EncodedImage newEi = m_Image.scaleImage32(widthScale, widthScale);
 			Bitmap img = newEi.getBitmap();
 			return img;
-
 		} catch (IOException e) {
 			System.out.println(&quot;Caugh an exception: &quot; + e.toString());
 		}
@@ -139,6 +144,12 @@ public class HTTPPhoto {
 				imageData = bStrm.toByteArray();
 				bStrm.close();
 			}
+			if (iStrm != null) {
+				iStrm.close();
+			}
+			if (httpConnection != null) {
+				httpConnection.close();
+			}
 			EncodedImage m_Image = EncodedImage.createEncodedImage(imageData, 0, imageData.length);
 			int oldHeight = m_Image.getHeight();
 			Font f = UiApplication.getUiApplication().getActiveScreen().getFont();
@@ -196,6 +207,12 @@ public class HTTPPhoto {
 				imageData = bStrm.toByteArray();
 				bStrm.close();
 			}
+			if (iStrm != null) {
+				iStrm.close();
+			}
+			if (httpConnection != null) {
+				httpConnection.close();
+			}
 			EncodedImage m_Image = EncodedImage.createEncodedImage(imageData, 0, imageData.length);
 			Bitmap img = m_Image.getBitmap();
 			return img;</diff>
      <filename>src/mobi/bbhn/brightberry/HTTPPhoto.java</filename>
    </modified>
    <modified>
      <diff>@@ -60,16 +60,26 @@ class PendingFriendsThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;Authorization&quot;, this.settings.getAuthHeader());
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			this.httpInput = this.httpConnection.openInputStream();
-			StringBuffer buffer = new StringBuffer();
-
-			int ch = 0;
-			while (ch != -1) {
-				ch = this.httpInput.read();
-				buffer.append((char)ch);
+			int rc = this.httpConnection.getResponseCode();
+			if (rc == 503) {
+				BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+			} else if (rc == 401 || rc == 403) {
+				BrightBerry.errorUnauthorized();
+			} else {
+				StringBuffer buffer = new StringBuffer();
+				int ch = 0;
+				while (ch != -1) {
+					ch = this.httpInput.read();
+					buffer.append((char)ch);
+				}
+				this.screen.updatePendingFriends(parseJSON(buffer.toString()));
+			}
+			if (this.httpInput != null) {
+				this.httpInput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
 			}
-
-			this.serverResponse = buffer.toString();
-			this.screen.updatePendingFriends(parseJSON(this.serverResponse));
 		} catch (IOException ex) {
 			ex.printStackTrace();
 		}</diff>
      <filename>src/mobi/bbhn/brightberry/PendingFriendsThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,6 @@ OF SUCH DAMAGE.
 
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 import javax.microedition.io.Connector;
 import javax.microedition.io.HttpConnection;
@@ -40,7 +39,6 @@ import net.rim.blackberry.api.browser.URLEncodedPostData;
 public class PlacemarkCreateThread extends Thread {
 	String url = &quot;http://brightkite.com/places/&quot;;
 	HttpConnection httpConnection = null;
-	InputStream httpInput = null;
 	DataOutputStream httpOutput = null;
 	String serverResponse = &quot;&quot;;
 	Object screen;
@@ -80,21 +78,34 @@ public class PlacemarkCreateThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			this.httpOutput = this.httpConnection.openDataOutputStream();
 			this.httpOutput.write(this.placemarkpost.getBytes());
-			this.httpInput = this.httpConnection.openInputStream();
 			int rc = httpConnection.getResponseCode();
 			if (this.caller.equals(&quot;search&quot;)) {
 				if (rc == 201) {
 					((SearchPlaceScreen) this.screen).plCreated(true);
+				} else if (rc == 503) {
+					BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+				} else if (rc == 401 || rc == 403) {
+					BrightBerry.errorUnauthorized();
 				} else {
 					((SearchPlaceScreen) this.screen).plCreated(false);
 				}
 			} else if (this.caller.equals(&quot;stream&quot;)) {
 				if (rc == 201) {
 					((StreamScreen) this.screen).plCreated(true);
+				} else if (rc == 503) {
+					BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+				} else if (rc == 401 || rc == 403) {
+					BrightBerry.errorUnauthorized();
 				} else {
 					((StreamScreen) this.screen).plCreated(false);
 				}
 			}
+			if (this.httpOutput != null) {
+				this.httpOutput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
+			}
 			System.out.println(&quot;Post was: &quot; + this.placemarkpost);
 			System.out.println(&quot;Auth was: &quot;+ Settings.getInstance().getAuthHeader());
 			System.out.println(&quot;Response code was: &quot; + rc);</diff>
      <filename>src/mobi/bbhn/brightberry/PlacemarkCreateThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -55,10 +55,17 @@ class PlacemarkCallback implements ListFieldCallback {
 		g.drawText(placemark[index].getDisplayLocation(), drawbmp.getWidth()+3, y+fontht, DrawStyle.ELLIPSIS);
     }
 	public Object get(ListField listField, int index) {
-        return null;
+        return placemark[index];
     }
     public int indexOfList(ListField listField, String prefix, int start) {
-        return listField.indexOfList(prefix, start);
+    	System.out.println(&quot;Into the indexOfList&quot;);
+    	for (int i=start; i &lt; placemark.length; i++) {
+			String name = (String) placemark[i].getName().toLowerCase();
+			if (name.startsWith(prefix.toLowerCase())) {
+				return i;
+			}
+		}
+		return -1;
     }
 	public int getPreferredWidth(ListField listField) {
 		return Display.getWidth();</diff>
      <filename>src/mobi/bbhn/brightberry/PlacemarkList.java</filename>
    </modified>
    <modified>
      <diff>@@ -43,7 +43,6 @@ import net.rim.device.api.ui.container.MainScreen;
 
 public class PlacemarkScreen extends MainScreen {
 	MenuItem updateItem;
-	MenuItem whereAmIItem;
 	Settings settings = Settings.getInstance();
 	String message;
 	PlacemarkScreen screen = this;
@@ -61,9 +60,6 @@ public class PlacemarkScreen extends MainScreen {
 	}
 
 	public PlacemarkScreen() {
-		Thread whereThread = new WhereAmIThread(this.screen);
-	    whereThread.start();
-	    
 		super.setTitle(new LabelField(&quot;BrightBerry Placemarks&quot;, 1152921504606846980L));
 		
 		this.checkinItem = new MenuItem(&quot;Checkin Here&quot;, 1, 10) {
@@ -138,15 +134,7 @@ public class PlacemarkScreen extends MainScreen {
 			}
 		};
 		
-		this.whereAmIItem = new MenuItem(&quot;Where Am I&quot;, 8, 10) {
-			public void run() {
-				Thread whereThread = new WhereAmIThread(PlacemarkScreen.this.screen);
-				whereThread.start();
-			}
-		};
-		
 		addMenuItem(this.updateItem);
-		addMenuItem(this.whereAmIItem);
 		addMenuItem(MenuItem.separator(9));
 		
 		if (settings.getPlacemarks() != null) {
@@ -154,11 +142,15 @@ public class PlacemarkScreen extends MainScreen {
 			this.list.setSize(settings.getPlacemarks().length);
 			this.list.setCallback(new PlacemarkCallback(settings.getPlacemarks()));
 			this.list.setRowHeight((int)(ListField.ROW_HEIGHT_FONT*2));
+			this.list.setSearchable(true);
 			add(this.list);
 		} else {
 			RichTextField noresults = new RichTextField(&quot;You have no placemarks set&quot;, 45035996273704960L);
 			add(noresults);
 		}
+		
+		LabelField locationLabel = new LabelField(&quot;You're checked in @ &quot; + BrightBerry.getCurrentPlace());
+		setStatus(locationLabel);
 	}
 
 	public void updateStatus(String message) {
@@ -173,16 +165,6 @@ public class PlacemarkScreen extends MainScreen {
 		});
 	}
 
-	public void updateLocation(String message) {
-		this.message = message;
-		UiApplication.getUiApplication().invokeLater(new Runnable() {
-			public void run() {
-				LabelField locationLabel = new LabelField(&quot;You're checked in @ &quot; + PlacemarkScreen.this.message);
-				PlacemarkScreen.this.setStatus(locationLabel);
-			}
-		});
-	}
-
 	public void updatePlacemarks(final Placemark[] placemarks) {
 		this.placemarks = placemarks;
 		UiApplication.getUiApplication().invokeLater(new Runnable() { </diff>
      <filename>src/mobi/bbhn/brightberry/PlacemarkScreen.java</filename>
    </modified>
    <modified>
      <diff>@@ -62,18 +62,26 @@ class PlacemarksUpdateThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;Authorization&quot;, this.settings.getAuthHeader());
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			this.httpInput = this.httpConnection.openInputStream();
-
-			StringBuffer buffer = new StringBuffer();
-
-			int ch = 0;
-			while (ch != -1) {
-				ch = this.httpInput.read();
-				buffer.append((char)ch);
+			int rc = this.httpConnection.getResponseCode();
+			if (rc == 503) {
+				BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+			} else if (rc == 401 || rc == 403) {
+				BrightBerry.errorUnauthorized();
+			} else {
+				StringBuffer buffer = new StringBuffer();
+				int ch = 0;
+				while (ch != -1) {
+					ch = this.httpInput.read();
+					buffer.append((char)ch);
+				}
+				this.screen.updatePlacemarks(parseJSON(buffer.toString()));
+			}
+			if (this.httpInput != null) {
+				this.httpInput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
 			}
-
-			this.serverResponse = buffer.toString();
-
-			this.screen.updatePlacemarks(parseJSON(this.serverResponse));
 		} catch (IOException ex) {
 			ex.printStackTrace();
 		}</diff>
      <filename>src/mobi/bbhn/brightberry/PlacemarkUpdateThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,6 @@ OF SUCH DAMAGE.
 
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 import javax.microedition.io.Connector;
 import javax.microedition.io.HttpConnection;
@@ -41,7 +40,6 @@ import net.rim.device.api.system.Alert;
 public class PostCommentThread extends Thread {
 	String url = &quot;http://brightkite.com/objects/&quot;;
 	HttpConnection httpConnection = null;
-	InputStream httpInput = null;
 	DataOutputStream httpOutput = null;
 	String serverResponse = &quot;&quot;;
 	PostCommentScreen screen;
@@ -68,7 +66,6 @@ public class PostCommentThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			this.httpOutput = this.httpConnection.openDataOutputStream();
 			this.httpOutput.write(this.comment.getBytes());
-			this.httpInput = this.httpConnection.openInputStream();
 			int rc = httpConnection.getResponseCode();
 			if (rc == 201) {
 				if (Alert.isVibrateSupported() &amp;&amp; settings.getVibrateOnPost()) {
@@ -76,8 +73,19 @@ public class PostCommentThread extends Thread {
 				}
 				this.screen.callPosted(true);
 			} else {
+				if (rc == 503) {
+					BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+				} else if (rc == 401 || rc == 403) {
+					BrightBerry.errorUnauthorized();
+				}
 				this.screen.callPosted(false);
 			}
+			if (this.httpOutput != null) {
+				this.httpOutput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
+			}
 	    } catch (IOException ex) {
 	    	ex.printStackTrace();
 	    }</diff>
      <filename>src/mobi/bbhn/brightberry/PostCommentThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -61,7 +61,6 @@ public class PostNoteScreen extends MainScreen implements FieldChangeListener {
 		}
 	};
 	private static boolean Posted;
-	private static String locationName;
 	private static String locationID;
 	
 	FieldChangeListener inputListener = new FieldChangeListener() {
@@ -77,12 +76,22 @@ public class PostNoteScreen extends MainScreen implements FieldChangeListener {
 	
 	// Post note at the current checked in location
 	public PostNoteScreen() {
-		Thread whereThread = new WhereAmIThread(this.screen);
-		whereThread.start();
-		
+		locationID = BrightBerry.getCurrentPlaceID();
 		setTitle(new LabelField(&quot;BrightBerry Post Note&quot;, Field.FIELD_HCENTER)); 
 		postBtn = new ButtonField(&quot;Post Note&quot;, ButtonField.CONSUME_CLICK);
 		postBtn.setChangeListener(this);
+		
+		VerticalFieldManager status = new VerticalFieldManager();
+		status.add(leftField);
+		status.add(new SeparatorField());
+		status.add(statusField);
+		setStatus(status);
+		statusField.setText(&quot;You're checked in @ &quot; + BrightBerry.getCurrentPlace());
+		note.setChangeListener(PostNoteScreen.this.inputListener);
+		add(note);
+		note.setCursorPosition(0);
+		add(postBtn);
+		addMenuItem(updateItem);
 	}
 	
 	// Post note about a location
@@ -132,25 +141,4 @@ public class PostNoteScreen extends MainScreen implements FieldChangeListener {
 				}
 			);
 	}
-	
-	public void updateLocation(String locName, String locID){
-		locationName = locName;
-		locationID = locID;
-		UiApplication.getUiApplication().invokeLater(
-			new Runnable() {
-				public void run() {
-					VerticalFieldManager status = new VerticalFieldManager();
-					status.add(leftField);
-					status.add(new SeparatorField());
-					status.add(statusField);
-					PostNoteScreen.super.setStatus(status);
-					PostNoteScreen.this.statusField.setText(&quot;You're checked in @ &quot; + PostNoteScreen.locationName);
-					PostNoteScreen.this.note.setChangeListener(PostNoteScreen.this.inputListener);
-					PostNoteScreen.this.add(note);
-					PostNoteScreen.this.note.setCursorPosition(0);
-					PostNoteScreen.this.add(postBtn);
-					PostNoteScreen.this.addMenuItem(updateItem);
-				}
-			});
-	}
 }</diff>
      <filename>src/mobi/bbhn/brightberry/PostNoteScreen.java</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,6 @@ OF SUCH DAMAGE.
 
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 import javax.microedition.io.Connector;
 import javax.microedition.io.HttpConnection;
@@ -41,7 +40,6 @@ import net.rim.device.api.system.Alert;
 public class PostNoteThread extends Thread {
 	String url = &quot;http://brightkite.com/places/&quot;;
 	HttpConnection httpConnection = null;
-	InputStream httpInput = null;
 	DataOutputStream httpOutput = null;
 	String serverResponse = &quot;&quot;;
 	PostNoteScreen screen;
@@ -68,7 +66,6 @@ public class PostNoteThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			this.httpOutput = this.httpConnection.openDataOutputStream();
 			this.httpOutput.write(this.note.getBytes());
-			this.httpInput = this.httpConnection.openInputStream();
 			int rc = httpConnection.getResponseCode();
 			if (rc == 201) {
 				if (Alert.isVibrateSupported() &amp;&amp; settings.getVibrateOnPost()) {
@@ -76,8 +73,19 @@ public class PostNoteThread extends Thread {
 				}
 				this.screen.callPosted(true);
 			} else {
+				if (rc == 503) {
+					BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+				} else if (rc == 401 || rc == 403) {
+					BrightBerry.errorUnauthorized();
+				}
 				this.screen.callPosted(false);
 			}
+			if (this.httpOutput != null) {
+				this.httpOutput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
+			}
 			System.out.println(&quot;Post was: &quot; + this.note);
 			System.out.println(&quot;Auth was: &quot;+ Settings.getInstance().getAuthHeader());
 			System.out.println(&quot;Response code was: &quot; + rc);</diff>
      <filename>src/mobi/bbhn/brightberry/PostNoteThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -81,7 +81,6 @@ public class PostPhotoScreen extends MainScreen implements FieldChangeListener {
 		}
 	};
 	boolean Posted;
-	private static String locationName;
 	private static String locationID;
 	private BrightBerryJournalListener _fileListener;
 	private BrightBerry _uiApp;
@@ -101,31 +100,28 @@ public class PostPhotoScreen extends MainScreen implements FieldChangeListener {
 	
 	// Post photo at the current checked in location from the app
 	public PostPhotoScreen() {
+		locationID = BrightBerry.getCurrentPlaceID();
 		_uiApp = (BrightBerry)UiApplication.getUiApplication();
     	_fileListener = new BrightBerryJournalListener(this);        
     	_uiApp.addFileSystemJournalListener(_fileListener);
-        	
-		Thread whereThread = new WhereAmIThread(this.screen);
-		whereThread.start();
 		setTitle(new LabelField(&quot;BrightBerry Post Photo&quot;, Field.FIELD_HCENTER));
 		postBtn = new ButtonField(&quot;Post Photo&quot;, ButtonField.CONSUME_CLICK);
 		postBtn.setChangeListener(this);
+		drawRest();
 	}
 	
 	// Post a photo at the current checked in location from file explorer
 	public PostPhotoScreen(String filename) {
+		locationID = BrightBerry.getCurrentPlaceID();
 		filetoupload = filename;
 	    int lastSlash = filename.lastIndexOf('/') + 1;
         String newfilename = filename.substring(lastSlash, filename.length());
 		this.fileName.setText(newfilename);
 		this.fromExplorer = true;
-		
-		Thread whereThread = new WhereAmIThread(this.screen);
-		whereThread.start();
 		setTitle(new LabelField(&quot;BrightBerry Post Photo&quot;, Field.FIELD_HCENTER));
 		postBtn = new ButtonField(&quot;Post Photo&quot;, ButtonField.CONSUME_CLICK);
 		postBtn.setChangeListener(this);
-		
+		drawRest();
 	}
 	
 	// Post photo about a location
@@ -155,6 +151,26 @@ public class PostPhotoScreen extends MainScreen implements FieldChangeListener {
 		Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA, new CameraArguments());
 	}
 	
+	public void drawRest() {
+		VerticalFieldManager status = new VerticalFieldManager();
+		status.add(leftField);
+		status.add(new SeparatorField());
+		status.add(statusField);
+		setStatus(status);
+		statusField.setText(&quot;You're checked in @ &quot; + BrightBerry.getCurrentPlace());
+		note.setChangeListener(PostPhotoScreen.this.inputListener);
+		note.setCursorPosition(0);
+		add(note);
+		add(fileName);
+		add(postBtn);
+		addMenuItem(updateItem);
+		if (fromExplorer == false) {
+			Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA, new CameraArguments());
+		} else {
+			drawPreview(filetoupload);
+		}
+	}
+	
 	public void fieldChanged(Field field, int context) {
 		if (filetoupload.length() &gt; 0) {
 			Status.show(&quot;Posting...&quot;);
@@ -186,33 +202,6 @@ public class PostPhotoScreen extends MainScreen implements FieldChangeListener {
 			);
 	}
 	
-	public void updateLocation(String locName, String locID){
-		locationName = locName;
-		locationID = locID;
-		UiApplication.getUiApplication().invokeLater(
-			new Runnable() {
-				public void run() {
-					VerticalFieldManager status = new VerticalFieldManager();
-					status.add(leftField);
-					status.add(new SeparatorField());
-					status.add(statusField);
-					PostPhotoScreen.super.setStatus(status);
-					PostPhotoScreen.this.statusField.setText(&quot;You're checked in @ &quot; + PostPhotoScreen.locationName);
-					PostPhotoScreen.this.note.setChangeListener(PostPhotoScreen.this.inputListener);
-					PostPhotoScreen.this.note.setCursorPosition(0);
-					PostPhotoScreen.this.add(note);
-					PostPhotoScreen.this.add(fileName);
-					PostPhotoScreen.this.add(postBtn);
-					PostPhotoScreen.this.addMenuItem(updateItem);
-					if (PostPhotoScreen.this.fromExplorer == false) {
-						Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA, new CameraArguments());
-					} else {
-						PostPhotoScreen.this.drawPreview(PostPhotoScreen.this.filetoupload);
-					}
-				}
-			});
-	}
-	
 	public void updateFileName (String filename) {
 		filetoupload = filename;
 		EventInjector.KeyEvent inject = new EventInjector.KeyEvent(EventInjector.KeyEvent.KEY_DOWN, Characters.ESCAPE, 0);</diff>
      <filename>src/mobi/bbhn/brightberry/PostPhotoScreen.java</filename>
    </modified>
    <modified>
      <diff>@@ -28,7 +28,6 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
 OF SUCH DAMAGE.
 */
 
-import java.io.DataOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
 
@@ -42,7 +41,7 @@ public class PostPhotoThread extends Thread {
 	String url = &quot;http://brightkite.com/places/&quot;;
 	HttpConnection httpConnection = null;
 	InputStream httpInput = null;
-	DataOutputStream httpOutput = null;
+	OutputStream os = null;
 	String serverResponse = &quot;&quot;;
 	PostPhotoScreen screen;
 	static Settings settings = Settings.getInstance();
@@ -58,21 +57,16 @@ public class PostPhotoThread extends Thread {
 	}
 	
 	public void run() {
-		HttpConnection conn = null;
-		OutputStream os = null;
-		InputStream is = null;
-
 		url += NetworkConfig.getConnectionParameters(settings.getConnectionMode());
 
 		try {
-			System.out.println(&quot;url:&quot; + url);
-			conn = (HttpConnection) Connector.open(url);
-			conn.setRequestProperty(&quot;User-Agent&quot;, BrightBerry.useragent);
-			conn.setRequestProperty(&quot;Content-Language&quot;, &quot;en-US&quot;);
-			conn.setRequestProperty(&quot;Authorization&quot;, settings.getAuthHeader());
-			conn.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
-			conn.setRequestMethod(HttpConnection.POST);
-			conn.setRequestProperty(&quot;Content-Type&quot;, &quot;multipart/form-data; boundary=---------------------------4664151417711&quot;);
+			this.httpConnection = (HttpConnection) Connector.open(url);
+			this.httpConnection.setRequestProperty(&quot;User-Agent&quot;, BrightBerry.useragent);
+			this.httpConnection.setRequestProperty(&quot;Content-Language&quot;, &quot;en-US&quot;);
+			this.httpConnection.setRequestProperty(&quot;Authorization&quot;, settings.getAuthHeader());
+			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
+			this.httpConnection.setRequestMethod(HttpConnection.POST);
+			this.httpConnection.setRequestProperty(&quot;Content-Type&quot;, &quot;multipart/form-data; boundary=---------------------------4664151417711&quot;);
 
 			System.out.println(&quot;File Name: file://&quot; + filename);
 			FileConnection fcon = (FileConnection)Connector.open(&quot;file://&quot; + filename);
@@ -109,7 +103,7 @@ public class PostPhotoThread extends Thread {
 			message2 += CrLf + &quot;-----------------------------4664151417711--&quot; + CrLf;
 
 			System.out.println(&quot;open os&quot;);
-			os = conn.openOutputStream();
+			os = this.httpConnection.openOutputStream();
 			
 			System.out.println(message0);
 			os.write(message0.getBytes());
@@ -138,14 +132,14 @@ public class PostPhotoThread extends Thread {
 			os.flush();
 
 			System.out.println(&quot;open is&quot;);
-			is = conn.openInputStream();
+			this.httpInput = this.httpConnection.openInputStream();
 
 			char buff = 512;
 			int len;
 			byte[] data = new byte[buff];
 			do {
 				System.out.println(&quot;READ&quot;);
-				len = is.read(data);
+				len = this.httpInput.read(data);
 
 				if (len &gt; 0) {
 					System.out.println(new String(data, 0, len));
@@ -153,32 +147,32 @@ public class PostPhotoThread extends Thread {
 			} while (len &gt; 0);
 
 			System.out.println(&quot;DONE&quot;);
-			int rc = conn.getResponseCode();
+			int rc = this.httpConnection.getResponseCode();
 			if (rc == 201) {
 				if (Alert.isVibrateSupported() &amp;&amp; settings.getVibrateOnPost()) {
 					Alert.startVibrate(2000);
 				}
 				screen.callPosted(true);
 			} else {
+				if (rc == 503) {
+					BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+				} else if (rc == 401 || rc == 403) {
+					BrightBerry.errorUnauthorized();
+				}
 				screen.callPosted(false);
 			}
 			System.out.println(&quot;Response code: &quot; + rc);
-		} catch (Exception e) {
-			e.printStackTrace();
-		} finally {
-			System.out.println(&quot;Close connection&quot;);
-			try {
-				os.close();
-			} catch (Exception e) {
+			if (this.os != null) {
+				this.os.close();
 			}
-			try {
-				is.close();
-			} catch (Exception e) {
+			if (this.httpInput != null) {
+				this.httpInput.close();
 			}
-			try {
-				conn.close();
-			} catch (Exception e) {
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
 			}
+		} catch (Exception e) {
+			e.printStackTrace();
 		}
 	}
 }</diff>
      <filename>src/mobi/bbhn/brightberry/PostPhotoThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -51,18 +51,15 @@ public class PrivacyGet {
 			httpConnection.setRequestProperty(&quot;Authorization&quot;, settings.getAuthHeader());
 			httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			InputStream httpInput = httpConnection.openInputStream();
-
 			StringBuffer buffer = new StringBuffer();
-
 			int ch = 0;
 			while (ch != -1) {
 				ch = httpInput.read();
 				buffer.append((char)ch);
 			}
-
-			String serverResponse = buffer.toString();
-			return parseJSON(serverResponse);
-
+			httpConnection.close();
+			httpInput.close();
+			return parseJSON(buffer.toString());
 		} catch (IOException e) {
 			Dialog.alert(&quot;Caught Exception&quot;);
 		}
@@ -71,12 +68,15 @@ public class PrivacyGet {
 	
 	private static boolean parseJSON(String json) {
 		JSONObject me = null;
+		System.out.println(&quot;/me/config.json Response: &quot; + json);
 		try {
 			me = new JSONObject(json);
 			String prvmode = me.getString(&quot;privacy_mode&quot;);
 			if (prvmode.equals(&quot;private&quot;)) {
+				System.out.println (&quot;Private&quot;);
 				return true;
 			} else {
+				System.out.println (&quot;Public&quot;);
 				return false;
 			}
 		} catch (Exception e) {</diff>
      <filename>src/mobi/bbhn/brightberry/PrivacyGet.java</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,6 @@ OF SUCH DAMAGE.
 
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 import javax.microedition.io.Connector;
 import javax.microedition.io.HttpConnection;
@@ -38,7 +37,6 @@ import javax.microedition.io.HttpConnection;
 public class PrivacyThread extends Thread {
 	String url = &quot;http://brightkite.com/me/config.json&quot;;
 	HttpConnection httpConnection = null;
-	InputStream httpInput = null;
 	DataOutputStream httpOutput = null;
 	String serverResponse = &quot;&quot;;
 	BrightBerryMain screen;
@@ -68,16 +66,26 @@ public class PrivacyThread extends Thread {
 				this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 				this.httpOutput = this.httpConnection.openDataOutputStream();
 				this.httpOutput.write(this.postmode.getBytes());
-				this.httpInput = this.httpConnection.openInputStream();
-				int rc = httpConnection.getResponseCode();
+				int rc = this.httpConnection.getResponseCode();
 				if (rc == 200) {
 					this.screen.callPrivacy(true);
 				} else {
+					if (rc == 503) {
+						BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+					} else if (rc == 401 || rc == 403) {
+						BrightBerry.errorUnauthorized();
+					}
 					this.screen.callPrivacy(false);
 				}
 			} else {
 				this.screen.callPrivacy(false);
 			}
+			if (this.httpOutput != null) {
+				this.httpOutput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
+			}
 	    } catch (IOException ex) {
 	    	ex.printStackTrace();
 	    }</diff>
      <filename>src/mobi/bbhn/brightberry/PrivacyThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -77,18 +77,26 @@ class SearchPlaceThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;Authorization&quot;, this.settings.getAuthHeader());
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			this.httpInput = this.httpConnection.openInputStream();
-
-			StringBuffer buffer = new StringBuffer();
-
-			int ch = 0;
-			while (ch != -1) {
-				ch = this.httpInput.read();
-				buffer.append((char)ch);
+			int rc = this.httpConnection.getResponseCode();
+			if (rc == 503) {
+				BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+			} else if (rc == 401 || rc == 403) {
+				BrightBerry.errorUnauthorized();
+			} else {
+				StringBuffer buffer = new StringBuffer();
+				int ch = 0;
+				while (ch != -1) {
+					ch = this.httpInput.read();
+					buffer.append((char)ch);
+				}
+				this.screen.updateSearch(parseJSON(buffer.toString()));
+			}
+			if (this.httpInput != null) {
+				this.httpInput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
 			}
-
-			this.serverResponse = buffer.toString();
-
-			this.screen.updateSearch(parseJSON(this.serverResponse));
 		} catch (IOException ex) {
 			ex.printStackTrace();
 		}</diff>
      <filename>src/mobi/bbhn/brightberry/SearchPlaceThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,6 @@ OF SUCH DAMAGE.
 
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 import javax.microedition.io.Connector;
 import javax.microedition.io.HttpConnection;
@@ -41,7 +40,6 @@ import net.rim.device.api.system.Alert;
 public class SendDirectMessageThread extends Thread {
 	String url = &quot;http://brightkite.com/people/&quot;;
 	HttpConnection httpConnection = null;
-	InputStream httpInput = null;
 	DataOutputStream httpOutput = null;
 	String serverResponse = &quot;&quot;;
 	SendDirectMessageScreen screen;
@@ -69,7 +67,6 @@ public class SendDirectMessageThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			this.httpOutput = this.httpConnection.openDataOutputStream();
 			this.httpOutput.write(this.note.getBytes());
-			this.httpInput = this.httpConnection.openInputStream();
 			int rc = httpConnection.getResponseCode();
 			if (rc == 201) {
 				if (Alert.isVibrateSupported() &amp;&amp; settings.getVibrateOnPost()) {
@@ -77,8 +74,19 @@ public class SendDirectMessageThread extends Thread {
 				}
 				this.screen.callPosted(true);
 			} else {
+				if (rc == 503) {
+					BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+				} else if (rc == 401 || rc == 403) {
+					BrightBerry.errorUnauthorized();
+				}
 				this.screen.callPosted(false);
 			}
+			if (this.httpOutput != null) {
+				this.httpOutput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
+			}
 	    } catch (IOException ex) {
 	    	ex.printStackTrace();
 	    }</diff>
      <filename>src/mobi/bbhn/brightberry/SendDirectMessageThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -107,23 +107,31 @@ class StreamThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;Authorization&quot;, this.settings.getAuthHeader());
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			this.httpInput = this.httpConnection.openInputStream();
-			StringBuffer buffer = new StringBuffer();
-			System.out.println(&quot;URL: &quot; + this.url);
-			System.out.println(&quot;Encoding: &quot; + this.httpConnection.getEncoding());
-
-			int ch = 0;
-			while (ch != -1) {
-				ch = this.httpInput.read();
-				buffer.append((char)ch);
-			}
-
-			this.serverResponse = buffer.toString();
-			System.out.println(&quot;Server Response: &quot; + this.serverResponse);
-			if (this.serverResponse.startsWith(&quot;[]&quot;)) {
-				this.screen.noPosts();
+			int rc = this.httpConnection.getResponseCode();
+			if (rc == 503) {
+				BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+			} else if (rc == 401 || rc == 403) {
+				BrightBerry.errorUnauthorized();
 			} else {
-				Stream[] places = parseJSON(this.serverResponse);
-				this.screen.updateStream(places);
+				StringBuffer buffer = new StringBuffer();
+				int ch = 0;
+				while (ch != -1) {
+					ch = this.httpInput.read();
+					buffer.append((char)ch);
+				}
+				this.serverResponse = buffer.toString();
+				if (this.serverResponse.startsWith(&quot;[]&quot;)) {
+					this.screen.noPosts();
+				} else {
+					Stream[] places = parseJSON(this.serverResponse);
+					this.screen.updateStream(places);
+				}
+			}
+			if (this.httpInput != null) {
+				this.httpInput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
 			}
 		} catch (IOException ex) {
 			ex.printStackTrace();</diff>
      <filename>src/mobi/bbhn/brightberry/StreamThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -41,6 +41,8 @@ import net.rim.device.api.ui.component.Dialog;
 public class UpgradeThread extends Thread {
 	static Settings settings = Settings.getInstance();
 	BrightBerryMain screen;
+	HttpConnection httpConnection = null;
+	InputStream httpInput = null;
 	
 	public UpgradeThread(BrightBerryMain BrightBerryMain) {
 		this.screen = BrightBerryMain;
@@ -50,24 +52,24 @@ public class UpgradeThread extends Thread {
 		try {
 			String url = &quot;http://bbhn.mobi/version.php?version=&quot; + BrightBerry.version;
 			url += NetworkConfig.getConnectionParameters(settings.getConnectionMode());
-			HttpConnection httpConnection = ((HttpConnection)Connector.open(url));
-			httpConnection.setRequestProperty(&quot;User-Agent&quot;, BrightBerry.useragent);
-			httpConnection.setRequestProperty(&quot;Content-Language&quot;, &quot;en-US&quot;);
-			httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
-			InputStream httpInput = httpConnection.openInputStream();
-
+			this.httpConnection = ((HttpConnection)Connector.open(url));
+			this.httpConnection.setRequestProperty(&quot;User-Agent&quot;, BrightBerry.useragent);
+			this.httpConnection.setRequestProperty(&quot;Content-Language&quot;, &quot;en-US&quot;);
+			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
+			this.httpInput = this.httpConnection.openInputStream();
 			StringBuffer buffer = new StringBuffer();
-
 			int ch = 0;
 			while (ch != -1) {
 				ch = httpInput.read();
 				buffer.append((char)ch);
 			}
-
-			String serverResponse = buffer.toString();
-			boolean upgrade = parseJSON(serverResponse);
-			this.screen.callUpgrade(upgrade);
-
+			this.screen.callUpgrade(parseJSON(buffer.toString()));
+			if (this.httpInput != null) {
+				this.httpInput.close();
+			}
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
+			}
 		} catch (IOException e) {
 			Dialog.alert(&quot;Caught Exception&quot;);
 		}</diff>
      <filename>src/mobi/bbhn/brightberry/UpgradeThread.java</filename>
    </modified>
    <modified>
      <diff>@@ -41,33 +41,11 @@ public class WhereAmIThread extends Thread {
 	HttpConnection httpConnection = null;
 	InputStream httpInput = null;
 	String serverResponse = &quot;&quot;;
-	private String LocationName;
-	private String LocationID;
-	private Object screen;
-	private String caller;
 	Settings settings = Settings.getInstance();
-
-	// Post Note Constructor
-	public WhereAmIThread(PostNoteScreen screen) {
-		this.caller = &quot;note&quot;;
-		this.screen = screen;
-	}
-
-	// Post Photo Constructor
-	public WhereAmIThread(PostPhotoScreen screen) {
-		this.caller = &quot;photo&quot;;
-		this.screen = screen;
-	}
+	private BrightBerryMain screen;
 	
 	// Main Screen Constructor
 	public WhereAmIThread(BrightBerryMain screen) {
-		this.caller = &quot;main&quot;;
-		this.screen = screen;
-	}
-	
-	// Placemark Constructor
-	public WhereAmIThread(PlacemarkScreen screen) {
-		this.caller = &quot;placemark&quot;;
 		this.screen = screen;
 	}
 
@@ -80,23 +58,25 @@ public class WhereAmIThread extends Thread {
 			this.httpConnection.setRequestProperty(&quot;Authorization&quot;, this.settings.getAuthHeader());
 			this.httpConnection.setRequestProperty(&quot;x-rim-transcode-content&quot;, &quot;none&quot;);
 			this.httpInput = this.httpConnection.openInputStream();
-			StringBuffer buffer = new StringBuffer();
-			int ch = 0;
-			while (ch != -1) {
-				ch = this.httpInput.read();
-				buffer.append((char)ch);
+			int rc = this.httpConnection.getResponseCode();
+			if (rc == 503) {
+				BrightBerry.displayAlert(&quot;Error&quot;, &quot;BrightKite is too busy at the moment try again later&quot;);
+			} else if (rc == 401 || rc == 403) {
+				BrightBerry.errorUnauthorized();
+			} else {
+				StringBuffer buffer = new StringBuffer();
+				int ch = 0;
+				while (ch != -1) {
+					ch = this.httpInput.read();
+					buffer.append((char)ch);
+				}
+				parseJSON(buffer.toString());
+			}
+			if (this.httpInput != null) {
+				this.httpInput.close();
 			}
-			this.serverResponse = buffer.toString();
-			System.out.println(&quot;Server response: &quot; + this.serverResponse);
-			parseJSON(this.serverResponse);
-			if (this.caller.equals(&quot;note&quot;)) {
-				((PostNoteScreen) this.screen).updateLocation(this.LocationName, this.LocationID);
-			} else if (this.caller.equals(&quot;main&quot;)) {
-				((BrightBerryMain) this.screen).updateLocation(this.LocationName);
-			} else if (this.caller.equals(&quot;photo&quot;)) {
-				((PostPhotoScreen) this.screen).updateLocation(this.LocationName, this.LocationID);
-			} else if (this.caller.equals(&quot;placemark&quot;)) {
-				((PlacemarkScreen) this.screen).updateLocation(this.LocationName);
+			if (this.httpConnection != null) {
+				this.httpConnection.close();
 			}
 	    } catch (IOException ex) {
 	    	ex.printStackTrace();
@@ -105,14 +85,15 @@ public class WhereAmIThread extends Thread {
 
 	private void parseJSON(String json) {
 		JSONObject me = null;
+		System.out.println(&quot;/me.json Response: &quot; + json);
 		try {
 			me = new JSONObject(json);
 			JSONObject place = me.getJSONObject(&quot;place&quot;);
-			this.LocationName = place.getString(&quot;name&quot;);
-			this.LocationID = place.getString(&quot;id&quot;);
-			BrightBerry.setFriendCount(me.getInt(&quot;friends_count&quot;));
+			BrightBerry.setCurrentPlace(place.getString(&quot;name&quot;));
+			BrightBerry.setCurrentPlaceID(place.getString(&quot;id&quot;));
 			BrightBerry.setUnreadMessages(me.getInt(&quot;unread_messages&quot;));
 			BrightBerry.setPendingFriends(me.getInt(&quot;pending_friends&quot;));
+			this.screen.updateCurrentPlace();
 		} catch (Exception e) {
 			System.out.println(e.getMessage());
 		}</diff>
      <filename>src/mobi/bbhn/brightberry/WhereAmIThread.java</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ab94de20fd215fa4fd634c1c68f6719d791f8290</id>
    </parent>
  </parents>
  <author>
    <name>Chris Hallgren</name>
    <email>challgren@hallgrennetwork.com</email>
  </author>
  <url>http://github.com/challgren/brightberry/commit/50579a4ccdf513da0b4239bc6bda8d8129614bd2</url>
  <id>50579a4ccdf513da0b4239bc6bda8d8129614bd2</id>
  <committed-date>2009-07-11T00:12:55-07:00</committed-date>
  <authored-date>2009-07-11T00:12:55-07:00</authored-date>
  <message>Up coming changings. Adding redexp me. Fixing issues where BrightBerry was cuasing a DDoS against Brightkite.</message>
  <tree>d1d6d2494cebe9dfd8996724fa3a7c3ade1bd9d9</tree>
  <committer>
    <name>Chris Hallgren</name>
    <email>challgren@hallgrennetwork.com</email>
  </committer>
</commit>
