Slight modifications and some debugging.