big fixes; new functions