Further attempts at performance optimization