Bug fixes and code cleanup in MSN functions.