minor cleanings + proper error/debug reporting