Use instanceof instead of isAssignableFrom where possible, close #342