fix template attribute
clean up code
merge master