fixed undefined variable notices; reduced consts