Implemented json export (fixes #10) and added comments