Refactored code into a simpler structure; changed module structure slightly.