Added contracts and tracing