Add extra JSON error handling, implement final, full functionality