Code review feedback.

* Remove indexing/slicing
* Use deepcopy for params
* Various other small fixes
* Spacing / comment fixes