Added code from sourceforge zip