code cleanup and freeomovie fix