Improvements and structure for profiles

Improved Logger and switched to it, a few more exception handlers, and
foundation for profiles.