Some minor changes to functions (not finished)