Add logging and additional error messaging