Cleaned up source code
Modified API design