Improved error message and exceptions when model is null.
Optimized imports and removed file headers.