bug fixes & logging