Added word wrap implementation and minor code cleanup