Small fixes and refactored.