More WIP. Try to automatically handle length. Needs review.