added app code
Fixed lots of things