Added improvements in unsafe code