Use realpath and parameter expansion
Add requirements to header
Some improvements in code