Added comments
Made encode_* return an Option
Change comments