Code cleaning and multi-os support; needs testing