Implement JSON API (Closes #9) and code smelling