Fixed incorrect function calls; renamed some for consistency.