Fixed some length logic, everything is still broken though.