Moved all functions into tiles module