Fixed bad exit (#121) and bug in CF wait handle usage