Tidy code. Switch to jsonlite. Remove implicit plyr dependency. Fix some bugs (getSegments).