Cleaned up estimator code and added comments