fix some issues according to Alexander's suggestions