Refactoring and prelim flocking code