Added: First JSON API + fixed several bugs