Library code - not included in project, as prob need rewriting