refactored a bunch of code; fixed many styling issues