fixed a bug with onClose(), better error messages, fixed bug with log()