Added @safe and @trusted where applicable.