Updated version, most of functionality totally reworked