Do some cleanup and get rid of possible circular references (#82)

Signed-off-by: Daniele Ricci <daniele.athome@gmail.com>