Sped up code and fixed issues; preliminarily works now.