Added API conformance and refactored code