Fixed database issues

Also fixed service custom template