Finished implementing extend_cycle

Finished implementing extend_cycle. Added some documenting comments. More documentation
and code cleanup desperately needed.