One please don't post files as downloads. Instead use the code formatting button, it looks like <>. The problem may be that you do not have all the variants. BlockRail adds more variants that need to be in you blockstate..
This line is your problem, you are telling the game that whenever there is a BlockState change. Block Change, etc. To delete your TileEntity. You need to compare the two IBlockStates and tell it when the TE should be removed.
Try use ICapabilitySerializable instead of ICapabilityProvider and use the Capabilities getStorage() function to deserialize and serialize the IItemHandler.
I don't believe it does since Configuration doesn't have support for Maps, but it does for arrays. So if you wanted to you could use one array and parse Strings numbers.
This cannot happen since ItemStacks cant, rather shouldn't be null. My guess is that it is your capability that is null or, you didn't use a NonNullList to store your ItemStacks.