Organized the code a bit into namespaces.