Realised the json decoded into proplists and cleaned up a lot of code.