General refactoring to clean up function signatures and calls