Added a --name switch. Improved exception handling.