Fixed parsing bugs, made parser more resilient