some more random code cleanup + no longer using deprecated function ereg