Minor changes and exception handling