Fixed some code and reference errors.