 # Home page with map
 mainContent = ->
 	Obs.observe ->
-		if mapReady.get()
+		if mapReady() and map?
 			# Limit scrolling to the bounds and also limit the zoom level
 			loc1 = L.latLng(Db.shared.get('game', 'bounds', 'one', 'lat'), Db.shared.get('game', 'bounds', 'one', 'lng'))
 			loc2 = L.latLng(Db.shared.get('game', 'bounds', 'two', 'lat'), Db.shared.get('game', 'bounds', 'two', 'lng'))
 			map.setMaxBounds(L.latLngBounds(loc1, loc2))
 			map._layersMinZoom = map.getBoundsZoom(L.latLngBounds(loc1, loc2))
 		Obs.onClean ->
-			map.setMaxBounds()
-			map._layersMinZoom = 0
+			if map?
+				map.setMaxBounds()
+				map._layersMinZoom = 0
 	showMap()
 	renderFlags()
 	loadMap()

					boundaryRectangle.addTo(map)
				Obs.onClean ->
					log 'onClean() rectangle + corners'
					if mapReady.get()
						map.removeLayer locationOne if locationOne?
						map.removeLayer locationTwo if locationTwo?
						map.removeLayer boundaryRectangle if boundaryRectangle?

		Geoloc.subscribe()
		# gamestate check
	Obs.observe ->
		hey = redraw.get();
		gameState = Db.shared.get('gameState')
		if gameState is 0 # Setting up game by user that added plugin
			setupContent()
