FIX: improve paths code generation to better support objects (fixes issue #920).