This reverts commit 048ce0876f due to bugs. Reworked change will be committed later hopefully.
048ce0876f