some performance improvements and improved user-error catching
some performance improvements and improved user-error catching