Change template parts to be more logical. Also added comments to files.