Fixed many bugs - version v.3