Tidied up maps code