Updating errors. Misc refactoring.