fixed a few bugs and improved naming conventions.