Fixed context saving/restoring