Began refactoring (using **kwargs instead of hardcoded keyword arguments. Finished up until commits (line 600)