fixed input parameters, and some cleanup