better logging, better exception handling