some bug fixes for parsing