Code reformated and moved to a more sane architeture