Optimization (in progress...) + small fixes