Add error logging, checks