Finished partition code, untested