Added stack marking and os-specific calls