Code cleanup
Reviewed error management
Code cleanup