Fixed bugs and added JSON methods