Fixed some parsing errors and added debug