Modifications to work on NS4.x and log tidy up code