Remove the need to specify target class

This is a rebased version of #224