Externalised the contacts map
Added docstrings