most recent batch of fixes, some syntax and logic errors fixed