Cleaning up, slight refactoring