Partially moved over yuqin's work to the proper rails structure. (NEEDS FIXING)