Refactoring

General code base improvements.