Started refactoring the code...

I need to read more about what I am doing, but I think there
is prob. a better way.