Lybraries, optimization and fixes