Solution fixes and refactor