Cleaned up calcState, also trying to merge properly this time.
Merge branch 'Tymko'