Fixed bug and restructured classes.