Started working on basic support for scopes

This still has a couple of theorical issues though.

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>