Some code clean ups, extendend example