refactored, and turned on all warnings