cleaned up totally for portability