Implemented random solver and other optimalisations