Refactored code, added non-constant width, fixed bugs