implemented middleman for organization. cleaned up javascript some.