Additional logging and error checks