rework system.php to add modularity and tweak output format