a much needed syntax and function cleanup