Fixed a bug and organized a bit