Fixed lots bugs