Finally finished Mathias coding ready to integrate