Added human understandable error message and fixed some glitches