A primary city may regulate railroad crossings, provide precautions, and prescribe rules for running engines or cars, and their speed, for prevention of accidents at crossings or on tracks or by fires from engines. It may regulate the running of buses and require heating and cleaning thereof. It may require reasonable lighting of railway crossings in such manner as the council may prescribe. If the owner or operator fails to comply, it may cause the same to be done and assess expense thereof against such railway company to be collected as other taxes and to be a lien on its property, or it may enforce compliance by action of mandamus. The city may enforce such regulations as are otherwise provided by law. It may require railways to keep flagmen at all railway street crossings where necessary to protect the public against injury to person or property, and require the installation, maintenance, and proper operation of gates, flashing signals, or other warning devices to insure such safety. It may compel railways to conform tracks to grades at any time established, to keep them level with the street surface, and it may compel railways to keep streets open, construct and keep in repair ditches, drains, sewers, and culverts along or under their right-of-way or tracks, and lay and maintain paving upon their whole right-of-way on paved streets.