Added API methods. Cleaned some code.