Apply the following changes by Toomas Kiisk <vix@cyber.ee>: