Fixed NPE and detailed exception message