Fix bug when moving entity near the lower border and add more documentation