cosmetics.
made variables const.
small code tweaks and cleanups.