Refactoring complete. Still need to better handle all those exceptions.