Fix somes bugs and add improvements