Lots of refactoring. Eliminated almost every warning.