port stuff from micrium project