Merge pull request #32 from ovidiuiliescu/2.4-preparation

Fixed removeAllCommands() bug that caused some commands not to be remove...
code beautification
using sychronization to remove layout problems
retrieving indeces correctly
fixing SET updates
Fixed possible NPE after the tail collection is cleared.