Improve class detection

Added support for detecting the final return type for a variable previously
created from a call chain (starting with a static call). The former code
only supported single static method calls.