cleaning up code. Removing unused classes, tweaking error handling.