Fixed NPE
Improved errors