added tags support, fixed some bugs