Various bug fixed and change template