Fixes missing targetClass variable

Had to throw another exception to handle `null` `target`.