Minor changes to readability and efficiency. Eventual code rewrite coming up soon for all branches.