Optimized constraints
Implemented global error handler