Added len function.
Removed unused code.