got rid of unused/unsupported template parameters, simplified functions, minimalized main.php