Fixing lib bugs, template sample