Fixed various issues with logic and style