New fixes for tags, also fix bug in functions