Various changes:

- better error handling (refactored error handling)
- moved some files around