fixed a bunch of logic for a large number of functions, really should've split this into separate commits