Add debug mode; catch more errors