Core code for Railpage