Code cleaning and structure/test