Refactored some things, set up logging, did a little organization.