fix function names. More restructuring.