adding partial template completion; misc bugs