I made some modifications to it and it looks (hopefully) a bit more sensible now.