Cleaned up parse code to more closely match docs