Refactoring and more type conversion.
Refactoring.
Cleaning up API.