many changes to layout, improve javascript code