Add support for returning class context or last object