big fixes & error logging