Tidied up. Everything seems to work as desired now! Woo hoo
Added a README and changed a funciton name for consistency.