Fixed issues with UI. Cleaned up model code