Revert "Replaced const vec& parameters with pass-by-value copies and did general cleanup"

This reverts commit 106a13aeec8c4c1acddbf1b10afe16e2a6c13629.