using perl "strict" to reduce errors and maintencene. Note outstanding questions (search for comments starting with "TODO")