Fixed issues with improper conditional closings (if/endif, etc.).