split up code into multiple files and made clustering configurable