Add error messages, fix NullPointerException.