Several modifications, ready version