Contract decorator

@bsoetaer 
There's a bunch of duplicate code, because the contract decorator didn't quite work with modules, but other than that, it's pretty straightforward.