Reorganized, added daemon support