Moved input/rerailer code around, see commit log