Extended object type check after having troubles with complex js objects. Not sure wether this is an elegant solution.
Modified extend method to accept deep flag.