Rewrite square length and filename assignment. Fixes #1