Add maven support and rearrange code.