Refactored a bit
Clean up some name spaces and visibility.