added remove_unused_params method, and associated changes