Refactoring and much better type safety.