Cleanup a bit, use typedef for types
Still have to work on seriallize function