Reorganize code, fix parameters, copy to README